---
output: 
  bookdown::pdf_document2: 
    keep_tex: true          #Saves the underlying LaTeX
    fig_caption: true       #This will make Figure Captions
    toc: false              #This sturns off table of contents; make this true if you want that
    number_sections: false  #Turns of section numbering
header-includes:
   - \usepackage{setspace}
   - \doublespacing
indent: true
title: "Anchoring Analysis"
author:
  - Kevin Arceneaux
  - Stephen P. Nicholson
#date: "`r format(Sys.time(), '%B %d, %Y')`"  #Uncomment this if you would like the data to appear
geometry: margin=1in 
fontfamily: mathpazo
fontsize: 12pt
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE) #You need this so that Rmd can run code and produce it in text.
```

```{r, child="AnchoringRecodes.Rmd"} 
#This calls the separate document where your code is placed
```

# Results for Main Paper 

# Table 1

```{r}
table(cces12[cces12$PrisonYears==1,]$anchor65)
table(cces12[cces12$LegTerms==1,]$anchor65)
table(cces12[cces12$UnempMonths==1,]$anchor65)
table(cces12[cces12$ImmigYears==1,]$anchor65)
table(cces12[cces12$IllegalYears==1,]$anchor65)
```

# Figure 1
```{r}
ul<-quantile(cces12[which(cces12$PrisonYears==1),]$SNI303, .90, na.rm=TRUE)
py<-ggplot(cces12[which(cces12$PrisonYears==1),], aes(x = as.factor(anchor65), y = SNI303)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5, color="gray30") +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  coord_cartesian(ylim = c(0, ul))  + 
  ylab('Prison Term for Murder\n(in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

ul<-quantile(cces12[which(cces12$LegTerms==1),]$SNI303, .90, na.rm=TRUE)
lt<-ggplot(cces12[which(cces12$LegTerms==1),], aes(x = as.factor(anchor65), y = SNI303)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5, color="gray30") +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  coord_cartesian(ylim = c(0, ul))  + 
  ylab('Maximum Legislative Term\n(in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

ul<-quantile(cces12[which(cces12$UnempMonths==1),]$SNI303, .90, na.rm=TRUE)
um<-ggplot(cces12[which(cces12$UnempMonths==1),], aes(x = as.factor(anchor65), y = SNI303)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5, color="gray30") +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Maximum Unemployment Benefits\n(in months)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

ul<-quantile(cces12[which(cces12$ImmigYears==1),]$SNI303, .90, na.rm=TRUE)
dy<-ggplot(cces12[which(cces12$ImmigYears==1),], aes(x = as.factor(anchor65), y = SNI303)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5, color="gray30") +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Citizenship Waiting Period for\nDocumented Immigrants (in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

ul<-quantile(cces12[which(cces12$IllegalYears==1),]$SNI303, .90, na.rm=TRUE)
udy<-ggplot(cces12[which(cces12$IllegalYears==1),], aes(x = as.factor(anchor65), y = SNI303)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5, color="gray30") +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Citizenship Waiting Period for\nUndocumented Immigrants (in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

tiff("Figure1.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(py, lt, um, dy, udy, nrow=2, ncol=3) 
dev.off()
```

# CCES 2012 Irrelevant Anchors Bayes Factors
```{r}
prisonBF<-cces12[cces12$PrisonYears==1,] %>%
  select(SNI303, anchor65)
lmBF(SNI303 ~ anchor65, data= na.omit(prisonBF))

legtermsBF<-cces12[cces12$LegTerms==1,] %>%
  select(SNI303, anchor65)
lmBF(SNI303 ~ anchor65, data= na.omit(legtermsBF))

unempBF<-cces12[cces12$UnempMonths==1,] %>%
  select(SNI303, anchor65)
lmBF(SNI303 ~ anchor65, data= na.omit(unempBF))

immigBF<-cces12[cces12$ImmigYears==1,] %>%
  select(SNI303, anchor65)
lmBF(SNI303 ~ anchor65, data= na.omit(immigBF))

undocBF<-cces12[cces12$IllegalYears==1,] %>%
  select(SNI303, anchor65)
lmBF(SNI303 ~ anchor65, data= na.omit(undocBF))
```

# Table 2
```{r}
table(qualtrics15[qualtrics15$IrrelTreat==2,]$anchor65)
table(qualtrics15[qualtrics15$IrrelTreat==3,]$anchor65)
table(qualtrics15[qualtrics15$IrrelTreat==1,]$anchor65)
```

# Figure 2

```{r}
#Figures
ul<-quantile(qualtrics15[which(qualtrics15$IrrelTreat==2),]$tax_irrel, .90, na.rm=TRUE)
ct<-ggplot(qualtrics15[which(qualtrics15$IrrelTreat==2),], aes(x = as.factor(anchor65), y = tax_irrel)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Cigarette Tax Preference\n(in dollars)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

ul<-quantile(qualtrics15[which(qualtrics15$IrrelTreat==3),]$tax_irrel, .90, na.rm=TRUE)
gt<-ggplot(qualtrics15[which(qualtrics15$IrrelTreat==3),], aes(x = as.factor(anchor65), y = tax_irrel)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Gas Tax Preference\n(in dollars)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

ul<-quantile(qualtrics15[which(qualtrics15$IrrelTreat==1),]$tax_irrel, .90, na.rm=TRUE)
mw<-ggplot(qualtrics15[which(qualtrics15$IrrelTreat==1),], aes(x = as.factor(anchor65), y = tax_irrel)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Minimum Wage Preference\n(in dollars)') +
  xlab('Irrelevant Anchor') +
  scale_x_discrete(labels=c("0" = "10", "1" = "65"))

tiff("Figure2.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(ct, gt, mw, nrow=2, ncol=2) 
dev.off()

```

# Qualtrics 2015 Irrelevant Anchors Bayes Factors
```{r}
cigtax15BF<-qualtrics15[qualtrics15$IrrelTreat==2,] %>%
  select(tax_irrel, anchor65)
lmBF(tax_irrel ~ anchor65, data= na.omit(cigtax15BF))

gastax15BF<-qualtrics15[qualtrics15$IrrelTreat==3,] %>%
  select(tax_irrel, anchor65)
lmBF(tax_irrel ~ anchor65, data= na.omit(gastax15BF))

minwage15<-qualtrics15[qualtrics15$IrrelTreat==1,] %>%
  select(tax_irrel, anchor65)
lmBF(tax_irrel ~ anchor65, data= na.omit(minwage15))
```

# Figure 3
```{r}
py<-ggplot(cces18, aes(x = IAnum, y = murder)) +
  geom_point() + geom_smooth(method=lm, se=FALSE, aes(color="Linear")) +
  geom_quantile(quantiles = 0.5, size=1, aes(color="Median")) +
  scale_color_manual(name="Regression Model", 
                     values = c("Linear"="black",
                                "Median"="orange")) +
  ylab('Prison Term for Murder\n(in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_continuous(breaks = c(0,20,40,60,80),
                     labels = c("G","20","40","60","80")) +
  theme_classic() 

lt<-ggplot(cces18, aes(x = IAnum, y = maxterm)) +
  geom_point() + geom_smooth(method=lm, se=FALSE, color="black") +
  geom_quantile(quantiles = 0.5, size=1, color="orange") +
  ylab('Maximum Legislative Term\n(in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_continuous(breaks = c(0,20,40,60,80),
                     labels = c("G","20","40","60","80")) +
  theme_classic() 

um<-ggplot(cces18, aes(x = IAnum, y = maxunemp)) +
  geom_point() + geom_smooth(method=lm, se=FALSE, color="black") +
  geom_quantile(quantiles = 0.5, size=1, color="orange") +
  ylab('Maximum Unemployment Benefits\n(in months)') +
  xlab('Irrelevant Anchor') +
  scale_x_continuous(breaks = c(0,20,40,60,80),
                     labels = c("G","20","40","60","80")) +
  scale_y_continuous(limits=c(0,100)) +
  theme_classic() 

dy<-ggplot(cces18, aes(x = IAnum, y = legalimmigwait)) +
  geom_point() + geom_smooth(method=lm, se=FALSE, color="black") +
  geom_quantile(quantiles = 0.5, size=1, color="orange") +
  ylab('Citizenship Waiting Period for\nDocumented Immigrants (in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_continuous(breaks = c(0,20,40,60,80),
                     labels = c("G","20","40","60","80")) +
  theme_classic() 

udy<-ggplot(cces18, aes(x = IAnum, y = undocimmigwait)) +
  geom_point() + geom_smooth(method=lm, se=FALSE, color="black") +
  geom_quantile(quantiles = 0.5, size=1, color="orange") +
  ylab('Citizenship Waiting Period for\nUndocumented Immigrants (in years)') +
  xlab('Irrelevant Anchor') +
  scale_x_continuous(breaks = c(0,20,40,60,80),
                     labels = c("G","20","40","60","80")) +
  scale_y_continuous(limits=c(0,100)) +
  theme_classic() 

legend<-get_legend(py)

py <- py + theme(legend.position="none")

tiff("Figure3.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(py, lt, um, dy, udy, legend, nrow=2, ncol=3) 
dev.off()
```

# CCES 2018 Irrelevant Anchors Bayes Factors
```{r}
murder18BF<-cces18 %>%
  select(murder, IAnum)
lmBF(murder ~ IAnum, data= na.omit(murder18BF))

maxterm18BF<-cces18 %>%
  select(maxterm, IAnum)
lmBF(maxterm ~ IAnum, data= na.omit(maxterm18BF))

maxunemp18BF<-cces18 %>%
  select(maxunemp, IAnum)
lmBF(maxunemp ~ IAnum, data= na.omit(maxunemp18BF))

legalimmigwait18BF<-cces18 %>%
  select(legalimmigwait, IAnum)
lmBF(legalimmigwait ~ IAnum, data= na.omit(legalimmigwait18BF))

undocimmigwait18BF<-cces18 %>%
  select(undocimmigwait, IAnum)
lmBF(undocimmigwait ~ IAnum, data= na.omit(undocimmigwait18BF))
```

# Table 3

```{r}
table(qualtrics15$PrisonHigh)
table(qualtrics15$SenateHigh)
table(qualtrics15$UnempWeeksHigh)
table(qualtrics15$UnempMonthsHigh)
table(qualtrics15$ImmigMonthsHigh)
table(qualtrics15$ImmigYearsHigh)
```

# Figure 4
```{r}
ul<-quantile(qualtrics15$prison, .99, na.rm=TRUE)
pterm<-ggplot(qualtrics15, aes(x = as.factor(PrisonHigh), y = prison)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Prison Term\nfor Murder\n(in years)') +
  xlab('Priston Term Anchor') +
  scale_x_discrete(labels=c("0" = "at least 2 years", "1" = "100 years"))

ul<-quantile(qualtrics15$senate, .95, na.rm=TRUE)
lterm<-ggplot(qualtrics15, aes(x = as.factor(SenateHigh), y = senate)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Maximum\nLegislative Term\n(in years)') +
  xlab('Legislative Term Anchor') +
  scale_x_discrete(labels=c("0" = "6 years", "1" = "16 years"))

q15df1<-data.frame(cbind(UnempWeeksHigh=qualtrics15$UnempWeeksHigh, unemp=qualtrics15$unemp))
q15df1<-na.omit(q15df1)
ul<-quantile(q15df1$unemp, .95, na.rm=TRUE)
ubweek<-ggplot(q15df1, aes(x = as.factor(UnempWeeksHigh), y = unemp)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Maximum\nUnemployment Benefits\n(in weeks)') +
  xlab('Unemployment Anchor') +
  scale_x_discrete(labels=c("0" = "14 weeks", "1" = "30 weeks"))

q15df2<-data.frame(cbind(UnempMonthsHigh=qualtrics15$UnempMonthsHigh, unemp=qualtrics15$unemp))
q15df2<-na.omit(q15df2)
ul<-quantile(q15df2$unemp, .95, na.rm=TRUE)
ubmonth<-ggplot(q15df2, aes(x = as.factor(UnempMonthsHigh), y = unemp)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Maximum\nUnemployment Benefits\n(in months)') +
  xlab('Unemployment Anchor') +
  scale_x_discrete(labels=c("0" = "3.5 months", "1" = "7.5 months"))

q15df3<-data.frame(cbind(ImmigMonthsHigh=qualtrics15$ImmigMonthsHigh, immig=qualtrics15$immig))
q15df3<-na.omit(q15df3)
ul<-quantile(q15df3$immig, .95, na.rm=TRUE)
immonth<-ggplot(q15df3, aes(x = as.factor(ImmigMonthsHigh), y = immig)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Waiting Period for\nDocumented Immigrants\n(in months)') +
  xlab('Waiting Period Anchor') +
  scale_x_discrete(labels=c("0" = "36 months", "1" = "60 months"))

q15df4<-data.frame(cbind(ImmigYearsHigh=qualtrics15$ImmigYearsHigh, immig=qualtrics15$immig))
q15df4<-na.omit(q15df4)
ul<-quantile(q15df4$immig, .95, na.rm=TRUE)
imyear<-ggplot(q15df4, aes(x = as.factor(ImmigYearsHigh), y = immig)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Waiting Period for\nDocumented Immigrants\n(in years)') +
  xlab('Waiting Period Anchor') +
  scale_x_discrete(labels=c("0" = "3 years", "1" = "5 years"))

tiff("Figure4.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(pterm, lterm, ubweek, ubmonth, immonth, imyear, nrow=3, ncol=2) 
dev.off()
```

# Table 4

```{r}
#Table 4, Row 1
table(cces12$CTtreatment)
#Table 4, row 2
table(cces12$GTtreatment)
```

# Figure 5

```{r}
c12df1<-data.frame(cbind(CTtreatment=cces12$CTtreatment, CigTaxPref=cces12$CigTaxPref, CTpartytreat=cces12$CTpartytreat))
c12df1<-na.omit(c12df1)

#Cigarette Tax Collapsed Treatment Figure
ul<-quantile(cces12$CigTaxPref, .90, na.rm=TRUE)
ctc<-ggplot(cces12, aes(x = as.factor(CigTaxHigh), y = CigTaxPref)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Cigarette Tax Preference (in dollars)') +
  xlab('Cigarette Tax Anchor') +
  scale_x_discrete(labels=c("0" = "$0.17", "1" = "$4.35"))

#Cigarette Tax Party Treatment Figure
ul<-quantile(c12df1$CigTaxPref, .90, na.rm=TRUE)
ctp<-ggplot(c12df1, aes(x = as.factor(CTtreatment), y = CigTaxPref, color=as.factor(CTpartytreat))) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  scale_color_manual(breaks = c("1", "2", "3"),
                     values=c("gray0", "coral", "cyan3")) +
  ylab('Cigarette Tax Preference (in dollars)') +
  xlab('Cigarette Tax Anchor') +
  scale_x_discrete(labels=c("1" = "$0.17", "2" = "$4.35",
                            "3" = "$0.17", "4"="$4.35", "5"="$0.17", "6"="$4.35")) +
  labs(color = "Party Treatment")+
  scale_color_discrete(labels=c("No Party Cue","Inparty Cue","Outparty Cue"))

c12df2<-data.frame(cbind(GTtreatment=cces12$GTtreatment, GasTaxPref=cces12$GasTaxPref, GTpartytreat=cces12$GTpartytreat))
c12df2<-na.omit(c12df2)

#Gas Tax Collapsed Treatment Figure
ul<-quantile(cces12$GasTaxPref, .80, na.rm=TRUE)
gtc<-ggplot(cces12, aes(x = as.factor(gasTaxHigh), y = GasTaxPref)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  ylab('Gas Tax Preference (in dollars)') +
  xlab('Gas Tax Anchor') +
  scale_x_discrete(labels=c("0" = "$0.08", "1" = "$0.49"))

#Gas Tax Party Treatment Figure
ul<-quantile(c12df2$GasTaxPref, .80, na.rm=TRUE)
gtp<-ggplot(c12df2, aes(x = as.factor(GTtreatment), y = GasTaxPref, color=as.factor(GTpartytreat))) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() + coord_cartesian(ylim = c(0, ul))  + 
  scale_color_manual(breaks = c("1", "2", "3"),
                     values=c("gray0", "coral", "cyan3")) +
  ylab('Gas Tax Preference (in dollars)') +
  xlab('Gas Tax Anchor') +
  scale_x_discrete(labels=c("1" = "$0.08", "2" = "$0.49",
                            "3" = "$0.08", "4"="$0.49", "5"="$0.08", "6"="$0.49")) +
  labs(color = "Party Treatment")+
  scale_color_discrete(labels=c("No Party Cue","Inparty Cue","Outparty Cue"))

tiff("Figure5.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(ctc, ctp, gtc, gtp, nrow=2, ncol=3,
             layout_matrix=cbind(c(1,3), c(2,4), c(2,4))) 
dev.off()
```

# Table 5

```{r}
#Table 5:column 1
table(cces18$GWtreatment)
#Table 5, Column 2
table(cces18$BTtreatment)
#Table 5, Column 3
table(cces18$ATtreatment)
``` 

# Figure 6

```{r}
c18df1<-data.frame(cbind(GWtreatment=cces18$GWtreatment, GunWaitPref=cces18$GunWaitPref, GWpartytreat=cces18$GWpartytreat))
c18df1<-na.omit(c18df1)

#Gun Wait Collapsed Treatment Figure
ul<-quantile(cces18$GunWaitPref, .90, na.rm=TRUE)
gwc<-ggplot(cces18, aes(x = as.factor(GWtreatment01), y = GunWaitPref)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=0.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  coord_cartesian(ylim = c(0, ul))  + 
  ylab('Gun Waiting Period Preference (in days)') +
  xlab('Gun Waiting Period Anchor') +
  scale_x_discrete(labels=c("0" = "3 Days", "1" = "20 Days"))


#Gun Wait Party Treatment Figure
ul<-quantile(c18df1$GunWaitPref, .90, na.rm=TRUE)
gwp<-ggplot(c18df1, aes(x = as.factor(GWtreatment), y = GunWaitPref, color=as.factor(GWpartytreat))) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  scale_color_manual(breaks = c("1", "2", "3"),
                     values=c("gray0", "coral", "cyan3")) +
  ylab('Gun Waiting Period Preference (in days)') +
  xlab('Gun Waiting Period Anchor') +
  coord_cartesian(ylim = c(0, ul))  + 
  scale_x_discrete(labels=c("1" = "3 Days", "2" = "20 Days",
                            "3" = "3 Days", "4"="20 Days", "5"="3 Days", "6"="20 Days")) +
  labs(color = "Party Treatment")+
  scale_color_discrete(labels=c("No Party Cue","Inparty Cue","Outparty Cue"))

c18df2<-data.frame(cbind(BTtreatment=cces18$BTtreatment, BorderTaxPref=cces18$BorderTaxPref, BTpartytreat=cces18$BTpartytreat))
c18df2<-na.omit(c18df2)

#Border Tax Collapsed Treatment Figure
ul<-quantile(cces18$BorderTaxPref, .90, na.rm=TRUE)
btc<-ggplot(cces18, aes(x = as.factor(BTtreatment01), y = BorderTaxPref)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  coord_cartesian(ylim = c(0, ul))  + 
  ylab('Border Tax Preference (in percentages)') +
  xlab('Border Tax Penalty Anchor') +
  scale_x_discrete(labels=c("0" = "5%", "1" = "35%"))


#Border Tax Party Treatment Figure
ul<-quantile(c18df2$BorderTaxPref, .90, na.rm=TRUE)
btp<-ggplot(c18df2, aes(x = as.factor(BTtreatment), y = BorderTaxPref, color=as.factor(BTpartytreat))) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  coord_cartesian(ylim = c(0, ul))  + 
  scale_color_manual(breaks = c("1", "2", "3"),
                     values=c("gray0", "coral", "cyan3")) +
  ylab('Border Tax Preference (in percentages)') +
  xlab('Border Tax Anchor') +
  scale_x_discrete(labels=c("1" = "5%", "2" = "35%",
                            "3" = "5%", "4"="35%", "5"="5%", "6"="35%")) +
  labs(color = "Party Treatment")+
  scale_color_discrete(labels=c("No Party Cue","Inparty Cue","Outparty Cue"))

c18df3<-data.frame(cbind(ATtreatment=cces18$ATtreatment, AnimalTestingPref=cces18$AnimalTestingPref, ATpartytreat=cces18$ATpartytreat))
c18df3<-na.omit(c18df3)

#Animal Testing Collapsed Treatment Figure
ul<-quantile(cces18$AnimalTestingPref, .80, na.rm=TRUE)
atc<-ggplot(cces18, aes(x = as.factor(ATtreatment01), y = AnimalTestingPref)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  coord_cartesian(ylim = c(0, ul))  + 
  ylab('Animal Testing Penalty Preference (in dollars)') +
  xlab('Animal Testing Penalty Anchor') +
  scale_x_discrete(labels=c("0" = "$500", "1" = "$5000"))

#Animal Testing Party Treatment Figure
ul<-quantile(c18df3$AnimalTestingPref, .85, na.rm=TRUE)
atp<-ggplot(c18df3, aes(x = as.factor(ATtreatment), y = AnimalTestingPref, color=as.factor(ATpartytreat))) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  coord_cartesian(ylim = c(0, ul)) +
  scale_color_manual(breaks = c("1", "2", "3"),
                     values=c("gray0", "coral", "cyan3")) +
  ylab('Animal Testing Penalty Preference (in dollars)') +
  xlab('Animal Testing Penalty Anchor') +
  scale_x_discrete(labels=c("1" = "$500", "2" = "$5000",
                            "3" = "$500", "4"="$5000", "5"="$500", "6"="$5000")) +
  labs(color = "Party Treatment")+
  scale_color_discrete(labels=c("No Party Cue","Inparty Cue","Outparty Cue"))

tiff("Figure6.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(gwc, gwp, btc, btp, atc, atp, nrow=3, ncol=3,
             layout_matrix=cbind(c(1,3,5), c(2,4,6), c(2,4,6))) 
dev.off()

```

# Supplemental Information

## Section 2: Descripitive Stats

### Table A2.1

```{r}
##CCES 2012
describe(cces12[cces12$PrisonYears==1,]$SNI303)
describe(cces12[cces12$LegTerms==1,]$SNI303)
describe(cces12[cces12$UnempMonths==1,]$SNI303)
describe(cces12[cces12$ImmigYears==1,]$SNI303)
describe(cces12[cces12$IllegalYears==1,]$SNI303)
describe(cces12[cces12$CTtreatment<7,]$CigTaxPref)
describe(cces12[cces12$GTtreatment<7,]$GasTaxPref)

##Qualtrics 2015
describe(qualtrics15[qualtrics15$IrrelTreat==2,]$tax_irrel) #Cig Tax 
describe(qualtrics15[qualtrics15$IrrelTreat==3,]$tax_irrel) #Gas Tax 
describe(qualtrics15[qualtrics15$IrrelTreat==1,]$tax_irrel) #Min Wage
describe(qualtrics15$prison)
describe(qualtrics15$senate)
describe(qualtrics15[is.na(qualtrics15$UnempMonthsHigh)=="FALSE",]$unemp)
describe(qualtrics15[is.na(qualtrics15$UnempWeeksHigh)=="FALSE",]$unemp)
describe(qualtrics15[is.na(qualtrics15$ImmigYearsHigh)=="FALSE",]$immig)
describe(qualtrics15[is.na(qualtrics15$ImmigMonthsHigh)=="FALSE",]$immig)

##CCES 2018
describe(cces18$murder)
describe(cces18$maxterm)
describe(cces18$maxunemp)
describe(cces18$legalimmigwait)
describe(cces18$undocimmigwait)

```

### Table A2.2

```{r}
#CCES 2012
describe(cces12$age)
describe(cces12$white)
describe(cces12$female)
describe(cces12$education)
describe(cces12$income_wmissing)
describe(cces12$partyid)
describe(cces12$conservative)

#Qualtrics 2018
describe(qualtrics15$age)
describe(qualtrics15$white)
describe(qualtrics15$female)
describe(qualtrics15$education)
describe(qualtrics15$income)
describe(qualtrics15$pid7)
describe(qualtrics15$ideology)

#CCES 2018
describe(cces18$age)
describe(cces18$white)
describe(cces18$female)
describe(cces18$education)
describe(cces18$income_wmissing)
describe(cces18$partyid)
describe(cces18$conservative)

```


## Section 3: Balance 

### Table A3.1: CCES 2012 Irrelevant Anchors
```{r}
b1<-lm(anchor65~age+white+female+education+income+incmiss+partyid+conservative, data=subset(cces12,PrisonYears==1)) 
b2<-lm(anchor65~age+white+female+education+income+incmiss+partyid+conservative, data=subset(cces12,LegTerms==1)) 
b3<-lm(anchor65~age+white+female+education+income+incmiss+partyid+conservative, data=subset(cces12,UnempMonths==1)) 
b4<-lm(anchor65~age+white+female+education+income+incmiss+partyid+conservative, data=subset(cces12,ImmigYears==1)) 
b5<-lm(anchor65~age+white+female+education+income+incmiss+partyid+conservative, data=subset(cces12,IllegalYears==1)) 
stargazer(b1, b2, b3, b4, b5,
          dep.var.caption = " ", 
          column.labels = c("Prison Term", "Legislative Term", "Unemployment", "Legal Immigration", "Undocumented Immigration"),
          type="html", out="A3.1.doc")
```

### Table A3.2: CCES 2012: Relevant Anchors, Cigarette Tax Treatment
```{r}
b6<-multinom(CTtreatment~age+white+female+education+income+incmiss+partyid+conservative, data=cces12)
stargazer(b6,
          dep.var.caption = " ", 
          column.labels = c("High Anchor, No Cue", "Low Anchor, Inparty Cue", "High Anchor, Inparty Cue", 
                            "Low Anchor, Outparty Cue", "High Anchor, Outparty Cue"),
          type="html", out="A3.2.doc")
```

### Table A3.3: CCES 2012: Relevant Anchors, Gas Tax Treatment
```{r}
b7<-multinom(GTtreatment~age+white+female+education+income+incmiss+partyid+conservative, data=cces12)
stargazer(b7,
          dep.var.caption = " ", 
          column.labels = c("High Anchor, No Cue", "Low Anchor, Inparty Cue", "High Anchor, Inparty Cue", 
                            "Low Anchor, Outparty Cue", "High Anchor, Outparty Cue"),
          type="html", out="A3.3.doc")
```

### Table A3.4: Qualtrics 2015 Irrelevant Anchors
```{r}
b8<-lm(anchor65~age+white+female+education+income+pid7+ideology, data=subset(qualtrics15,IrrelTreat==2)) 
b9<-lm(anchor65~age+white+female+education+income+pid7+ideology, data=subset(qualtrics15,IrrelTreat==2)) 
b10<-lm(anchor65~age+white+female+education+income+pid7+ideology, data=subset(qualtrics15,IrrelTreat==1)) 
stargazer(b8, b9, b10, 
          dep.var.caption = " ", 
          column.labels = c("Cigarette Tax", "Gas Tax", "Minimum Wage"),
          type="html", out="A3.4.doc")
```

### Table A3.5: Qualtrics 2015 Relevant Anchors
```{r}
b11<-lm(PrisonHigh~age+white+female+education+income+pid7+ideology, data=qualtrics15) 
b12<-lm(SenateHigh~age+white+female+education+income+pid7+ideology, data=qualtrics15) 
b13<-lm(UnempWeeksHigh~age+white+female+education+income+pid7+ideology, data=qualtrics15) 
b14<-lm(UnempMonthsHigh~age+white+female+education+income+pid7+ideology, data=qualtrics15) 
b15<-lm(ImmigMonthsHigh~age+white+female+education+income+pid7+ideology, data=qualtrics15) 
b16<-lm(ImmigYearsHigh~age+white+female+education+income+pid7+ideology, data=qualtrics15) 
stargazer(b11, b12, b13, b14, b15, b16,
          dep.var.caption = " ", 
          column.labels = c("Prison Term", "Legislative Term", "Unemployment (Weeks)", "Unemployment (Months)", 
                            "Immigration (Months)", "Immigration (Years)"),
          type="html", out="A3.5.doc")
```

### Table A3.6: CCES 2018 Irrelevant Anchors
```{r}
b17<-lm(IAnum~age+white+female+education+income+incmiss+partyid+conservative, data=cces18)
stargazer(b17,
          dep.var.caption = " ", 
          column.labels = c("Continuous Anchor Treatment"),
          type="html", out="A3.6.doc")
```

### Table A3.7: CCES 2018 Relevant Anchors, Gun Waiting Period
```{r}
b18<-multinom(GWtreatment~age+white+female+education+income+incmiss+partyid+conservative, data=cces18)
stargazer(b18,
          dep.var.caption = " ", 
          column.labels = c("High Anchor, No Cue", "Low Anchor, Inparty Cue", "High Anchor, Inparty Cue", 
                            "Low Anchor, Outparty Cue", "High Anchor, Outparty Cue"),
          type="html", out="A3.7.doc")
```

### Table A3.8: CCES 2018 Relevant Anchors, Border Wall Tax
```{r}
b19<-multinom(BTtreatment~age+white+female+education+income+incmiss+partyid+conservative, data=cces18)
stargazer(b19,
          dep.var.caption = " ", 
          column.labels = c("High Anchor, No Cue", "Low Anchor, Inparty Cue", "High Anchor, Inparty Cue", 
                            "Low Anchor, Outparty Cue", "High Anchor, Outparty Cue"),
          type="html", out="A3.8.doc")
```

### Table A3.9: CCES 2018 Relevant Anchors, Animal Testing
```{r}
b20<-multinom(ATtreatment~age+white+female+education+income+incmiss+partyid+conservative, data=cces18)
stargazer(b20,
          dep.var.caption = " ", 
          column.labels = c("High Anchor, No Cue", "Low Anchor, Inparty Cue", "High Anchor, Inparty Cue", 
                            "Low Anchor, Outparty Cue", "High Anchor, Outparty Cue"),
          type="html", out="A3.9.doc")
```

### Table A3.10: CCES 2018 Relevant Anchors, Gas Tax Replication
```{r}
b21<-multinom(GTtreatment~age+white+female+education+income+incmiss+partyid+conservative, data=cces18)
stargazer(b21,
          dep.var.caption = " ", 
          column.labels = c("High Anchor, No Cue", "Low Anchor, Inparty Cue", "High Anchor, Inparty Cue", 
                            "Low Anchor, Outparty Cue", "High Anchor, Outparty Cue"),
          type="html", out="A3.10.doc")
```

## Section 4: Results

### Table A4.1: CCES 2012 Irrelevant Anchors Results
```{r}
prison<-rq(SNI303 ~ anchor65, data= cces12[cces12$PrisonYears==1,])
summary(prison, se = "boot")
legterms<-rq(SNI303 ~ anchor65, data= cces12[cces12$LegTerms==1,])
summary(legterms, se = "boot")
unemp<-rq(SNI303 ~ anchor65, data= cces12[cces12$UnempMonths==1,])
summary(unemp, se = "boot")
immig<-rq(SNI303 ~ anchor65, data= cces12[cces12$ImmigYears==1,])
summary(immig, se = "boot")
undoc<-rq(SNI303 ~ anchor65, data= cces12[cces12$IllegalYears==1,])
summary(undoc, se = "boot")
```

### Table A4.2: Qualtrics 2015 Irrelevant Anchors Results
```{r}
cigtax15<-rq(tax_irrel ~ anchor65, data= qualtrics15[qualtrics15$IrrelTreat==2,])
summary(cigtax15, se = "boot")
gastax15<-rq(tax_irrel ~ anchor65, data= qualtrics15[qualtrics15$IrrelTreat==3,])
summary(gastax15, se = "boot")
minwage15<-rq(tax_irrel ~ anchor65, data= qualtrics15[qualtrics15$IrrelTreat==1,])
summary(minwage15, se = "boot")
```

### Table A4.3: CCES 2018 Irrelevant Anchors Results
```{r}
m1<-rq(murder ~ IAnum, data = cces18)
summary(m1, se = "boot")
m2<-rq(maxterm ~ IAnum, data = cces18)
summary(m2, se = "boot")
m3<-rq(maxunemp ~ IAnum, data = cces18)
summary(m3, se = "boot")
m4<-rq(legalimmigwait ~ IAnum, data = cces18)
summary(m4, se = "boot")
m5<-rq(undocimmigwait ~ IAnum, data = cces18)
summary(m5, se = "boot")
```

### Table A4.4: Qualtrics 2015 Relevant Anchors
```{r}
prison15<-rq(prison ~ PrisonHigh, data= qualtrics15)
summary(prison15, se = "boot")
senate15<-rq(senate ~ SenateHigh, data= qualtrics15)
summary(senate15, se = "boot")
unempweek15<-rq(unemp ~ UnempWeeksHigh, data= qualtrics15)
summary(unempweek15, se = "boot")
unempmonth15<-rq(unemp ~ UnempMonthsHigh, data= qualtrics15)
summary(unempmonth15, se = "boot")
immigmonth15<-rq(immig ~ ImmigMonthsHigh, data= qualtrics15)
summary(immigmonth15, se = "boot")
immigyear15<-rq(immig ~ ImmigYearsHigh, data= qualtrics15)
summary(immigyear15, se = "boot")
```

### Table A4.5: CCES 2012 Relevant Anchors
```{r}
ct_ct<-rq(CigTaxPref ~ CigTaxHigh, data = cces12)
summary(ct_ct, se = "boot")
ct_pt<-rq(CigTaxPref ~ factor(CTtreatment), data = cces12)
summary(ct_pt, se = "boot")

gt_ct<-rq(GasTaxPref ~ gasTaxHigh, data = cces12)
summary(gt_ct, se = "boot")
gt_pt<-rq(GasTaxPref ~ factor(GTtreatment), data = cces12)
summary(gt_pt, se = "boot")
```

### Table A4.6: CCES 2018 Relevant Anchors
```{r}
gw_ct<-rq(GunWaitPref ~ GWtreatment01, data = cces18)
summary(gw_ct, se = "boot")
gw_pt<-rq(GunWaitPref ~ factor(GWtreatment), data = cces18)
summary(gw_pt, se = "boot")
bt_ct<-rq(BorderTaxPref ~ BTtreatment01, data = cces18)
summary(bt_ct, se = "boot")
bt_pt<-rq(BorderTaxPref ~ factor(BTtreatment), data = cces18)
summary(bt_pt, se = "boot")
at_ct<-rq(AnimalTestingPref ~ ATtreatment01, data = cces18)
summary(at_ct, se = "boot")
at_pt<-rq(AnimalTestingPref ~ factor(ATtreatment), data = cces18)
summary(at_pt, se = "boot")
```

## Section 5: Robustness

### Table A5.1: Does party moderate party cue effects? 

```{r}
ct_pt_int<-rq(CigTaxPref ~ factor(CTtreatment)*Democrat, data = cces12)
summary(ct_pt_int, se = "boot")
describe(cces12[is.na(cces12$Democrat)==FALSE,]$CigTaxPref) #For number of observations  
gt_pt_int<-rq(GasTaxPref ~ factor(GTtreatment)*Democrat, data = cces12)
summary(gt_pt_int, se = "boot")
describe(cces12[is.na(cces12$Democrat)==FALSE,]$GasTaxPref) #For number of observations 

gw_pt_int<-rq(GunWaitPref ~ factor(GWtreatment)*Democrat, data = cces18)
summary(gw_pt_int, se = "boot")
describe(cces18[is.na(cces18$Democrat)==FALSE,]$GunWaitPref) #For number of observations  
bt_pt_int<-rq(BorderTaxPref ~ factor(BTtreatment)*Democrat, data = cces18)
summary(bt_pt_int, se = "boot")
describe(cces18[is.na(cces18$Democrat)==FALSE,]$BorderTaxPref) #For number of observations
at_pt_int<-rq(AnimalTestingPref ~ factor(ATtreatment)*Democrat, data = cces18)
summary(at_pt_int, se = "boot")
describe(cces18[is.na(cces18$Democrat)==FALSE,]$AnimalTestingPref) #For number of observations
```

### Gas Tax Replication 2018

```{r}
c18df4<-data.frame(cbind(GTtreatment=cces18$GTtreatment, GasTaxPref=cces18$GasTaxPref, GTpartytreat=cces18$GTpartytreat))
c18df4<-na.omit(c18df4)

#Gas Tax Collapsed Treatment Figure
ul<-quantile(cces18$GasTaxPref, .90, na.rm=TRUE)
gtc18<-ggplot(cces18, aes(x = as.factor(GTtreatment01), y = GasTaxPref)) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  coord_cartesian(ylim = c(0, ul))  +  
  ylab('Gas Tax Preference (in cents)') +
  xlab('Gas Tax Anchor') +
  scale_x_discrete(labels=c("0" = "$0.12", "1" = "$0.58"))

#Gas Tax Party Treatment Figure
ul<-quantile(c18df4$GasTaxPref, .90)
gtp18<-ggplot(c18df4, aes(x = as.factor(GTtreatment), y = GasTaxPref, color=as.factor(GTpartytreat))) +
  geom_boxplot(notch = TRUE) +
  geom_quasirandom(alpha = 0.5, size=.5) +
  theme(legend.position = 'none') +
  theme_classic() +
  scale_color_manual(breaks = c("1", "2", "3"),
                     values=c("gray0", "coral", "cyan3")) +
  ylab('Gas Tax Preference (in cents)') +
  xlab('Gas Tax Anchor') +
  coord_cartesian(ylim = c(0, ul))  +
  scale_x_discrete(labels=c("1" = "$0.12", "2" = "$0.58",
                            "3" = "$0.12", "4"="$0.58", "5"="$0.12", "6"="$0.58")) +
  labs(color = "Party Treatment")+
  scale_color_discrete(labels=c("No Party Cue","Inparty Cue","Outparty Cue"))

tiff("CCES18gastaxREPL.tiff", width = 11, height = 11, units = 'in', res = 300)  
grid.arrange(gtc18, gtp18, nrow=1, ncol=3,
             layout_matrix=cbind(c(1), c(2), c(2))) 
dev.off()
```

```{r}
gt_ct18<-rq(GasTaxPref ~ GTtreatment01, data = cces18)
summary(gt_ct18, se = "boot")
gt_pt18<-rq(GasTaxPref ~ factor(GTtreatment), data = cces18)
summary(gt_pt18, se = "boot")
```